package com.mz.hotel.manage.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.mz.hotel.manage.entiy.Admin;


public class AdminDaoImpl implements AdminDao{
	
	public  Admin findHoteAdminByuserName(String userName){
		Admin admin=null;
		String sql="select * from admin where userName=?";
		
		DBUtilPreparedStatement dbUtil=new DBUtilPreparedStatement();
		String userName1=userName;
		String[]params={userName1};
		ResultSet rs=dbUtil.selectToResultSet(sql, params);
		try {
			if(rs.next()){
				admin=new Admin();
				admin.setUserId(rs.getInt("userId"));
				admin.setUserName(rs.getString("userName"));
				admin.setPassWord(rs.getString("passWord"));
				admin.setRealName(rs.getString("realName"));
				admin.setRoleId(rs.getInt("roleId"));
				admin.setStatus(rs.getInt("status"));
				admin.setCreateTime(rs.getDate("createTime"));
				admin.setUpdateUser(rs.getInt("updateTime"));
				admin.setUpdateTime(rs.getDate("updateTime"));
				admin.setCreateUser(rs.getInt("createUser"));
				
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		dbUtil.close();
		return admin;
	}
	
}

